require(["config"],function () {
    require(["jquery","idcode","md5","jquery.validation"],function () {
        $(function () {
            $(".top").load("shareHeader.html");
            $(".foot").load("shareFooter.html");
            //登录校验
            $.idcode.setCode();
            $("#myform").validate({
                submitHandler : function(){
                    if($.idcode.validateCode()){
                        $.ajax({
                            url : "../../server/login.php",
                            data : {
                                uname : $("[name=uname]").val(),
                                upwd : $.md5($("[name=upwd]").val())
                            },
                            type : "post",
                            dataType : "json"
                        }).done(function(res){
                            console.log(res);
                            if(res.status == 1){
                                sessionStorage.setItem("ifLogin", JSON.stringify(res.data));
                                window.location.assign("homePage.html")
                            }
                            alert(res.msg);
                        })
                    } else {
                        alert("验证码错误");
                    }
                    return false;
                }
            });

        })
    })
})